<template>
    <div class="wwww">
        <van-nav-bar title="登录" left-text="返回" left-arrow @click-left="onClickLeft" />
        <van-password-input :value="value" v-show="inp" :info="info1" :error-info="errorInfo" :focused="showKeyboard"
            @focus="showKeyboard = true" />
        <van-number-keyboard v-model="value" :show="showKeyboard" @blur="showKeyboard = false" />
    </div>
</template>

<script>
import axios from "axios";
export default {
    data() {
        return {
            show: "",
            list: {},
            value: '',
            errorInfo: '',
            showKeyboard: true,
            inp: true,
            info1: "密码为 6 位数字",
            list2:[],
        }
    },
    created() {
        this.getList();
    },
    methods: {
        onClickLeft() {
            this.$router.push({ path: '/friends' })
        },
        getList() {
            axios({
                url: "/api/user/getUserById",
                method: "GET",
                params: {
                    id: 1
                }
            }).then((res) => {
                this.list2 = res.data;
            });
        }
    },
    watch: {
        value(value) {
            if (value.length === 6 && value !== this.list2.userPwd) {
                this.errorInfo = '密码错误';
            } else if (value.length === 6 && value == this.list2.userPwd) {
                this.showKeyboard = false;
                this.errorInfo = "";
                this.inp = false;
                this.info1 = ""
            }
        },
    },
}
</script>

<style>
.content {
    padding: 16px 16px 160px;
}
</style>